0 && $text !== '') { $u = commenterByToken($token); if ($u) { commentAdd($photoId, (int)$u['id'], limitText($text, 1000)); } } $redirect = './?photo_id=' . $photoId; if ($token !== '') { $redirect .= '&viewer=' . urlencode($token); } header('Location: ' . $redirect); exit; } $sections = sectionsAll(); $activeSectionId = (int)($_GET['section_id'] ?? 0); $activePhotoId = (int)($_GET['photo_id'] ?? 0); $welcomeText = settingGet('welcome_text', 'Добро пожаловать в галерею. Выберите раздел слева, чтобы посмотреть фотографии.'); $photo = $activePhotoId > 0 ? photoById($activePhotoId) : null; $comments = $photo ? commentsByPhoto($activePhotoId) : []; $photos = $activeSectionId > 0 ? photosBySection($activeSectionId) : []; function h(string $v): string { return htmlspecialchars($v, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'); } function assetUrl(string $path): string { $f=__DIR__ . '/' . ltrim($path,'/'); $v=is_file($f)?(string)filemtime($f):(string)time(); return $path . '?v=' . rawurlencode($v); } function limitText(string $text, int $len): string { return function_exists('mb_substr') ? mb_substr($text, 0, $len) : substr($text, 0, $len); } function serveImage(): never { $fileId = (int)($_GET['file_id'] ?? 0); if ($fileId < 1) { http_response_code(404); exit; } $f = photoFileById($fileId); if (!$f) { http_response_code(404); exit; } $abs = __DIR__ . '/' . ltrim((string)$f['file_path'], '/'); if (!is_file($abs)) { http_response_code(404); exit; } if ((string)$f['kind'] !== 'after') { header('Content-Type: ' . ((string)$f['mime_type'] ?: 'application/octet-stream')); header('Content-Length: ' . (string)filesize($abs)); header('Cache-Control: private, max-age=60'); header('X-Robots-Tag: noindex, nofollow'); readfile($abs); exit; } outputWatermarked($abs, (string)$f['mime_type']); } function outputWatermarked(string $path, string $mime): never { $text = 'photo.andr33v.ru'; if (extension_loaded('imagick')) { $im = new Imagick($path); $draw = new ImagickDraw(); $draw->setFillColor(new ImagickPixel('rgba(255,255,255,0.22)')); $draw->setFontSize(max(18, (int)($im->getImageWidth() / 24))); $draw->setGravity(Imagick::GRAVITY_SOUTHEAST); $im->annotateImage($draw, 20, 24, -15, $text); header('Content-Type: ' . ($mime !== '' ? $mime : 'image/jpeg')); $im->setImageCompressionQuality(88); echo $im; $im->clear(); $im->destroy(); exit; } [$w, $h, $type] = @getimagesize($path) ?: [0,0,0]; $img = match ($type) { IMAGETYPE_JPEG => @imagecreatefromjpeg($path), IMAGETYPE_PNG => @imagecreatefrompng($path), IMAGETYPE_GIF => @imagecreatefromgif($path), IMAGETYPE_WEBP => function_exists('imagecreatefromwebp') ? @imagecreatefromwebp($path) : null, default => null, }; if (!$img) { readfile($path); exit; } $font = 5; $color = imagecolorallocatealpha($img, 255, 255, 255, 90); $x = max(5, $w - (imagefontwidth($font) * strlen($text)) - 15); $y = max(5, $h - imagefontheight($font) - 12); imagestring($img, $font, $x, $y, $text, $color); header('Content-Type: image/jpeg'); imagejpeg($img, null, 88); imagedestroy($img); exit; } ?> Фотогалерея

Фотогалерея

0 && $photo): ?>

← к разделу

До обработки
После обработки (watermark)

Комментарии

Комментарии может оставлять только пользователь с персональной ссылкой.

·

Фотографии

В разделе пока нет фотографий.